import {reqCategoryList,reqGetBannerList,reqFloorList} from '@/api'
const state = {
    useMock: true,
    //根据接口返回值初始化
    categoryList:[],
    //轮播图
    bannerList:[],
    floorList:[],
}
const actions = {
    async categoryList({commit}){
        /* console.log(123)
        console.log(reqCategoryList()) */
        let result = await reqCategoryList();
     /*    console.log(result); */
    
        if (result.code == 200) {
            commit("CATEGORYLIST", result.data)
        }
    },
    //轮播图
    async getBannerList({commit}){
       
        let result = await reqGetBannerList();
        /* console.log(result); 
        console.log(result.code); */
        if (result.code == 200) {
            commit("GETBANNERLIST", result.data)
        }
    },
    //底下轮播图
    async getFloorList({commit}){
       
        let result = await reqFloorList();
        /* console.log(result); 
        console.log(result.code); */
        if (result.code == 200) {
            commit("GETFLOORLIST", result.data)
        }
    }
    
}
const mutations = {
    CATEGORYLIST(state,categoryList) {
        state.categoryList = categoryList;
    },
    GETBANNERLIST(state,bannerList) {
        state.bannerList = bannerList
    },
    GETFLOORLIST(state,floorList) {
        state.floorList = floorList
    },
}
//计算属性
const getters = {}

export default {
    namespace:true,
    state,
    mutations,
    actions,
    getters
}